package com.punai.customer.controller;

import com.punai.common.annotation.Log;
import com.punai.common.core.controller.BaseController;
import com.punai.common.core.domain.AjaxResult;
import com.punai.common.core.page.TableDataInfo;
import com.punai.common.enums.BusinessType;
import com.punai.customer.domain.CusLinkGxfeeCategory;
import com.punai.customer.domain.contants.CusConstants;
import com.punai.customer.service.ICusLinkGxfeeCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 工序分包费用项 关联 材机分类Controller
 * 
 * @author ruoyi
 * @date 2022-12-09
 */
@RestController
@RequestMapping("/cus/linkGxFeeCategory")
public class CusLinkGxfeeCategoryController extends BaseController
{
    @Autowired
    private ICusLinkGxfeeCategoryService dmcLinkGxfeeCategoryService;

    /**
     * 查询工序分包费用项 关联 材机分类列表
     */
    @PreAuthorize("@ss.hasPermi('dmc:linkGxFeeCategory:list')")
    @GetMapping("/list")
    public TableDataInfo list(CusLinkGxfeeCategory dmcLinkGxfeeCategory)
    {
        startPage();
        List<CusLinkGxfeeCategory> list = dmcLinkGxfeeCategoryService.selectDmcLinkGxfeeCategoryList(dmcLinkGxfeeCategory);
        return getDataTable(list);
    }

    /**
     * 获取工序分包费用项 关联 材机分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('dmc:linkGxFeeCategory:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(dmcLinkGxfeeCategoryService.selectDmcLinkGxfeeCategoryById(id));
    }

    /**
     * 新增工序分包费用项 关联 材机分类
     */
    @PreAuthorize("@ss.hasPermi('dmc:linkGxFeeCategory:add')")
    @Log(title = CusConstants.GX_NAME + "关联材机分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CusLinkGxfeeCategory dmcLinkGxfeeCategory)
    {
        return toAjax(dmcLinkGxfeeCategoryService.insertDmcLinkGxfeeCategory(dmcLinkGxfeeCategory));
    }

    /**
     * 修改工序分包费用项 关联 材机分类
     */
    @PreAuthorize("@ss.hasPermi('dmc:linkGxFeeCategory:edit')")
    @Log(title = CusConstants.GX_NAME + "关联材机分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CusLinkGxfeeCategory dmcLinkGxfeeCategory)
    {
        return toAjax(dmcLinkGxfeeCategoryService.updateDmcLinkGxfeeCategory(dmcLinkGxfeeCategory));
    }

    /**
     * 删除工序分包费用项 关联 材机分类
     */
    @PreAuthorize("@ss.hasPermi('dmc:linkGxFeeCategory:remove')")
    @Log(title = CusConstants.GX_NAME + "关联材机分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dmcLinkGxfeeCategoryService.deleteDmcLinkGxfeeCategoryByIds(ids));
    }
}
